package com.bytezero.overload;

import java.io.PrintStream;

/*
 * 
 * public class ValueTransferTest4
 *{
 *	public static void main(String[] args)
 * {
 *		 int a =10;
 *		 int b =10;
	 	 
		 method(a,b);  // 在不改变原题情况下，调用method  输出a=100 b = 100
		 
		 System.out.println(a);
		 System.out.println(b);
		 
	}
 * 
 */
public class ValueTransferTest4
{
	public static void main(String[] args)
	{

		
		
		
		 int a =10;
		 int b =10;
		 
		 method(a,b);  //
		 
		 System.out.println("a = "+a);
		 System.out.println("b = "+b);
		 
	}
	
	//方式一
//	public  static void method(int a,int b)
//	{
//		a = a*10;
//		b = b*10;
//		System.out.println(a);
//	    System.out.println(b);
//		System.exit(0);
//	   
//		
//	}
	
	//方式二
	public  static void method(int a,int b)
	{
		PrintStream ps = new PrintStream(System.out)
				{
					@Override
					public void println(String x)
					{
						if("a = 10".equals(x))
						{
							x ="a = 100";
						
						}
						else if("b = 10".equals(x))	
							{
								x = "b = 200";
							}
							super.println(x);
						
					}
					
				};
				System.setOut(ps);
				
			
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
